<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>国省自检--${fns:getConfig('productName')}</title>
<link rel="stylesheet" href="${ctx}/styles/gsjcss/common.css">
<script type="text/javascript">
function btnClick(){
	var url = '${ctx}/bridgeMainten/search.do?projectId=${fns:encodeParamUrl(projectId)}&menuId=${fns:encodeParamUrl(menuId)}';
	var data = {};
	if($('#btnSearch').length>0){ //有搜索按钮的情况下 获取条件进行搜索
		//将条件提取出来 
		//将条件存入data中
		//ajax请求   得到数据
		data['retrieval'] = getJson('condition');
		loadData(url,data);
	} else {
		loadData(url,data);
	}
}
//ajax执行成功之后的回调方法
function loadDataToTable(data){
	var attment = data['att'];
	var bridgelist = data['bridgeList'];
	var tunnellist = data['tunnelList'];
	var checkList = data['checkList'];
	var markList = data['markList'];
	loadAttachment(attment);
	if($('#checkitem').length>0){
		$('#checkitem tbody').empty();
	    var tr = "";
		for (var j = 0; j < bridgelist.length; j++) {
			tr +="<tr><td>"+bridgelist[j].bridgeName+"</td><td>"+bridgelist[j].district+"</td><td>"+bridgelist[j].manageDuty+"</td></tr>";
		}
		for (var j = 0; j < tunnellist.length; j++) {
			tr +="<tr><td>"+tunnellist[j].tunnelname+"</td><td>"+tunnellist[j].district+"</td><td>"+tunnellist[j].manageduty+"</td></tr>";
		}
		
		$('#checkitem tbody').append(tr);
	}
	
	//返回评分结果
	if(data['flag']){
		//每次搜索前清空表格
		$('#checkResult #btList').empty();
		var result="";
		var content = '<span>注：一下内容需根据实际检查结果来具体给分</span>'+
					  '<table id="btList" style="width:98%;text-align:center;margin-top:5px;" border="1"><thead><tr>'+
					  '<th>序号</th><th>地市</th><th>桥梁名称/隧道名称</th><th>责任划分</th><th>信息公开</th><th>档案管理</th><th>桥梁工程师</th></tr>'+
					  '</thead><tbody></tbody></table>';			  
		$('#checkResult').append(content);
		
		var k =0;
		for (var i = 0; i < bridgelist.length; i++) {
			k++;
			result += '<tr><td>'+parseInt(i+1)+'</td><td>深圳</td><td>'+bridgelist[i].bridgeName+'</td>';
			if (checkList[0] == 1) {
				result += '<td>明确</td>';
			} else {
				result +='<td></td>';
			}
			if (checkList[1] == 1) {
				result += '<td>到位</td>';
			}else {
				result +='<td></td>';
			}
			if (checkList[2] == 1) {
				result += '<td>到位</td>';
			}else {
				result +='<td></td>';
			}
			result += '<td>'+bridgelist[i].manageDuty+'</td>';
			result += '</tr>';
		}
		for (var i = 0; i < tunnellist.length; i++) {
			result += '<tr><td>'+parseInt(i+1+k)+'</td><td>深圳</td><td>'+tunnellist[i].tunnelname+'</td>';
			if (checkList[0] == 1) {
				result += '<td>明确</td>';
			} else {
				result +='<td></td>';
			}
			if (checkList[1] == 1) {
				result += '<td>到位</td>';
			}else {
				result +='<td></td>';
			}
			if (checkList[2] == 1) {
				result += '<td>到位</td>';
			}else {
				result +='<td></td>';
			}
			result += '<td>'+tunnellist[i].manageduty+'</td>';
			result += '</tr>';
		}
		result += '<tr><td colspan="3">检查得分</td><td>'+markList[0]+'</td><td>'+markList[1]+'</td><td>'+markList[2]+'</td><td>'+markList[6]+'</td></tr>'
		
		$('#checkResult tbody').append(result);
		
		//每次搜索前清空表格
		$('#checkResult #maList').empty();
		var result1="";
		var content1 = '<table id="maList" style="width:98%;text-align:center;margin-top:5px;" border="1"><thead><tr>'+
					  '<th>检查项目</th><th>检查结果</th><th>检查得分</th><th>总得分</th><th>完善度</th></tr>'+
					  '</thead><tbody></tbody></table>';			  
		$('#checkResult').append(content1);
		
			result1 += '<tr><td>资金保障</td>';
			if (checkList[3] == 1) {
				result1 += '<td>良好</td>';
			}else {
				result1 +='<td></td>';
			}
			result1 += '<td>'+markList[3]+'</td><td class="sumTd" rowspan="6">'+data['sum']+'</td><td class="perTd" rowspan="6">'+data['percent']+'%</td></tr>';
			
			result1 += '<tr><td>挂牌督办</td>';
			if (checkList[4] == 1) {
				result1 += '<td>良好</td>';
			}else {
				result1 +='<td></td>';
			}
			result1 += '<td>'+markList[4]+'</td></tr><tr><td>分类处置</td>';
			if (checkList[7] == 1) {
				result1 += '<td>良好</td>';
			}else {
				result1 +='<td></td>';
			}
			result1 += '<td>'+markList[7]+'</td></tr><tr><td>定期培训</td>';
			if (checkList[5] == 1) {
				result1 += '<td>良好</td>';
			}else {
				result1 +='<td></td>';
			}
			result1 += '<td>'+markList[5]+'</td></tr>';
			if (0 == data['type']){
				result1 += '<tr><td>'+parseInt(data['endTime'] - 2)+'年报告</td>';
				if (checkList[8] == 2) {
					result1 += '<td rowspan="2">做到</td>';
				}else if (checkList[8] == 1) {
					result1 +='<td rowspan="2">缺少一年</td>';
				} else {
					result1 +='<td rowspan="2">缺少两年</td>';
				}
				result1 += '<td rowspan="2">'+markList[8]+'</td></tr>';
				result1 += '<tr><td>'+parseInt(data['endTime'] - 1)+'年报告</td></tr>';
			} else if (1 == data['type']) {
				result1 += '<tr><td>'+parseInt(data['endTime'] - 1)+'年报告</td>';
				if (checkList[8] == 1) {
					result1 +='<td>做到</td>';
				} else {
					result1 +='<td>缺少</td>';
				}
				result1 += '<td>'+markList[8]+'</td></tr>';
			}
		$('#checkResult #maList tbody').append(result1);
	}
}
</script>
</head>
<body>
	<div id="x_top"></div>
	<tags:message content="${msg}" />
	<c:if test="${not empty checkTable.id}">
		<div style="text-align:center">
			<a href="javascript:void(0);" class="btn btn-primary" onclick="downWord('${ctx}/bridgeMainten/downWord.do?projectId=${fns:encodeParamUrl(projectId)}&menuId=${fns:encodeParamUrl(menuId)}');" id= "btnDown" role="button" ><div id="x_v"></div></a>
		</div>
	</c:if>
	<form id="checkForm" class="form-horizontal"  method="POST"  name="checkForm" action="${ctx}/bridgeMainten/save.do?left=${fns:encodeParam(left)}&parentId=${fns:encodeParam(parentId)}&projectId=${fns:encodeParam(projectId)}&menuId=${fns:encodeParam(menuId)}&leftChild=${fns:encodeParam(leftChild)}">
		<input type="hidden" name="token" value="${token}">
		<div id="show">
			<div id="showTable" class="showTable">
				<jsp:include page="/WEB-INF/views/check/common.jsp"/> 
				<div class="model">
					<div>
						<legend>三、检查条件及设置</legend>
						<div class="content-title" id="condition">
							<div style="float:left;margin-right:10px;margin-top:5px;">
								<div>
									<span>桥梁名称:</span>
									<select name="bridgeName" id="bridgeName" style="width:130px;padding-left:0px;padding-right:0px;">
										<option value="">请选择</option>
										<c:forEach items="${fns:getAllBridgeBasicInfo()}" var="bridgeBasicInfo"  varStatus="idxStatus">
											<option value="${bridgeBasicInfo.id}">${bridgeBasicInfo.bridgeName}</option>
										</c:forEach>
									</select>
									<span>隧道名称:</span>
									<select name="tunnelName" id="tunnelName" style="width:130px;padding-left:0px;padding-right:0px;">
										<option value="">请选择</option>
										<c:forEach items="${fns:getAllTunnelInfo()}" var="tunnelInfo"  varStatus="idxStatus">
											<option value="${tunnelInfo.id}">${tunnelInfo.tunnelname}</option>
										</c:forEach>
									</select>
								</div>
								<div>
									<span>责任划分明确或信息公开或档案管理到位每项得分<font style="color:red;">*</font>：</span>
									<input type='text' name = "yearFull" id="yearFull" value="0.5" class="required conInput"/>
									<span>桥梁工程师安排明确，定期培训良好每项得分<font style="color:red;">*</font>：</span>
									<input type='text' name = "yearPart" id="yearPart" value="1" class="required conInput"/>
								</div>
								<div>
									<span>每个公路机构桥梁工程师安排模糊或没有定期培训扣分<font style="color:red;">*</font>：</span>
									<input type='text' name = "reserveMark" id="reserveMark" value="0.25" class="required conInput"/>
									<span>资金保障良好或挂牌督办执行良好的每项得分<font style="color:red;">*</font>：</span>
									<input type='text' name = "poitMark" id="poitMark" value="2" class="required conInput"/>
								</div>
								<div>
									<span>资金保障良好或挂牌督办执行一般的每项得分<font style="color:red;">*</font>：</span>
									<input type='text' name = "fourthStepScore" id="fourthStepScore" value="1" class="required conInput"/>
									<span>分类处置良好得分<font style="color:red;">*</font>：</span>
									<input type='text' name = "firstStepScore" id="firstStepScore" value="0.5" class="required conInput"/>
								</div>
								<div>
									<span>分类处置一般得分<font style="color:red;">*</font>：</span>
									<input type='text' name = "secondStepScore" id="firstStepScore" value="0.3" class="required conInput"/>
									<span>最后两年每年年度报告完整得分<font style="color:red;">*</font>：</span>
									<input type='text' name = "thirdStepScore" id="thirdStepScore" value="1" class="required conInput"/>
								</div>
							</div>
							<div id="x_s" style="float:right">
								<div class="x_ico"></div>
								<a href="#javascript:void(0)" onclick= "btnClick();"  id= "btnSearch" role="button" >搜索&nbsp;</a>
							</div>
						</div>
					</div>
				</div>
				<div class="model">
					<div>
						<legend>四、检索结果</legend>
						<div class="content-title">
							<div class="tabbox">
								<div class="tab">
									<a href="javascript:;" class='on'>桥隧记录</a>
									<c:forEach items="${childMenuList}" var="menu"  varStatus="idxStatus">
										<a href="javascript:;">${menu.name}</a>
									</c:forEach>
							    </div>
							    <div class="content">
							    	<ul>
								    	<li>
								    		<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="checkitem">
											    <thead>
												    <th>桥梁(隧道)名称</th>
												    <th>区</th>
												    <th>负责桥梁工程师</th>
												</thead>
										    	<tbody>
											    					
											    </tbody>
									    	</table>
								    	</li>
							    		<c:forEach items="${childMenuList}" var="menu"  varStatus="idxStatus">
							    			<c:if test="${idxStatus.index >= 0}">
								    			<li>
								    				<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="${menu.tag}">
										    			<thead>
										    				<th>序号</th>
											    			<th>操作</th>
											    			<th>发文单位</th>
											    			<th>上传用户</th>
											    			<th>文件名</th>
											    			<th>发文日期</th>
											    			<th>上传日期</th>
											    			<th>文件大小</th>
											    			<th>文件类型</th>
											    		</thead>
									    				<tbody>
										    						
										    			</tbody>
								    				</table>
								    			</li>
							    			</c:if>
							    		</c:forEach>
							        </ul>
							    </div>
							</div>
						</div>
					</div>
				</div>
				<div class="model">
					<div>
						<legend>五、检查评分</legend>
						<div class="content-title" id="checkResult">
						
						</div>
					</div>
				</div>
				<div class="model">
					<div class="content-btn">
						<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存" />
						&nbsp;&nbsp;&nbsp;&nbsp;
						<input id="btnCancel" class="btn" type="button" value="返 回" onclick="toBack()" />
					</div>
				</div>
			</div>
		</div>
	</form>
	<script src="${ctxStatic}/js/check/checkCommon.js" type="text/javascript"></script>
</body>
</html>